package singleton.pattern.Demo2;

/**
 * Created by DELL
 * Date: 2019/9/28.
 * Time: 13:37
 */
class MakeACaption {
    private static MakeACaption _caption;
    //We make the constructor private to prevent the use of "new"
    private MakeACaption(){}
    //线程安全
    public static synchronized MakeACaption get_caption() {
        if(_caption == null){
            _caption = new MakeACaption();
            System.out.println("New Caption selected in our team");
        }else{
            System.out.println("You already have a Caption for your team");
            System.out.println("Send him for the toss");
        }
        return _caption;
    }
}
